package com.kusen.village.raise.util;

import com.alibaba.fastjson.JSON;
import com.kusen.village.raise.entity.jsonbean.HopefulJson;
import com.kusen.village.raise.entity.jsonbean.HopefulJsonDto;

/**
 * @description: json处理器
 * @author: ghl
 * @create: 2021-10-13 10:44
 **/
public class JsonUtil {

    /**
     * 获取来自Hopeful topic的主题数据
     * @param jsonData
     * @return
     */
    public static HopefulJson getJsonDataFromHopeful(String jsonData){
    HopefulJson newHopefulJson = JSON.parseObject(jsonData, HopefulJson.class);
    return  newHopefulJson;
}

    /**
     * 得到json数据向mqtt发送数据
     * @param hopefulJson
     * @return
     */
   public static String getJson(HopefulJsonDto hopefulJson){
       String s = JSON.toJSONString(hopefulJson);
       return s;
   }
}
